/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 battlefield_terrain_map.h

	$Header: /resource_editor/battlefield_terrain_map.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( BATTLEFIELD_TERRAIN_MAP_H_INCLUDED )
#define BATTLEFIELD_TERRAIN_MAP_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "abstract_tile.h"
#include "counted_ptr.h"
#include "owned_ptr.h"
#include "terrain.h"

struct t_map_point_2d;
class t_metatile_map;
template < typename t_elem >
class t_quad;
struct t_screen_point;

// -----------------------------------------------------------------------
// t_battlefield_terrain_tile class
// -----------------------------------------------------------------------

class t_battlefield_terrain_tile : public t_abstract_tile
{
public:
	// Constructor
	t_battlefield_terrain_tile();
};

inline t_battlefield_terrain_tile::t_battlefield_terrain_tile()
{
	set_terrain( k_terrain_grass );
	set_terrain_subtype( 0 );
}

// -----------------------------------------------------------------------
// t_battlefield_terrain_tile_vertex class
// -----------------------------------------------------------------------

class t_battlefield_terrain_tile_vertex : public t_abstract_tile_vertex
{
};

// -----------------------------------------------------------------------
// t_battlefield_terrain_map class
// -----------------------------------------------------------------------

class t_battlefield_terrain_map : public t_counted_object
{
public:
	// Types
	typedef t_battlefield_terrain_tile			t_tile;
	typedef t_battlefield_terrain_tile_vertex	t_tile_vertex;

	// Static member functions
	static t_screen_point get_view_size();

	// Constructor/Destructor
	t_battlefield_terrain_map();
	t_battlefield_terrain_map( t_battlefield_terrain_map const & other );
	~t_battlefield_terrain_map();

	// Member functions
	void							establish_transitions();
	t_metatile_map const &			get_metatile_map() const;
	t_screen_point					get_screen_point( t_map_point_2d const & point ) const;
	int								get_size() const;
	t_tile &						get_tile( t_map_point_2d const & point );
	t_tile const &					get_tile( t_map_point_2d const & point ) const;
	int								get_tile_row_end( int row ) const;
	int								get_tile_row_start( int row ) const;
	t_tile_vertex &					get_tile_vertex( t_map_point_2d const & point );
	t_tile_vertex const &			get_tile_vertex( t_map_point_2d const & point ) const;
	t_quad< t_tile_vertex & >		get_tile_vertex_quad( t_map_point_2d const & point );
	t_quad< t_tile_vertex const & >	get_tile_vertex_quad( t_map_point_2d const & point ) const;
	int								get_tile_vertex_row_end( int row ) const;
	int								get_tile_vertex_row_start( int row ) const;
	int								get_vertex_size() const;
	bool							is_valid( t_map_point_2d const & point ) const;
	bool							read( std::streambuf& stream );
	void							recalculate_vertex_lighting();
	void							reset_height( t_map_point_2d const& point,
						                          int height );
	void							set_river_height();
	bool							write( std::streambuf& stream ) const;

	// Operators
	t_battlefield_terrain_map & operator=( t_battlefield_terrain_map const & other );

private:
	// Types
	class t_impl;

	// Data members
	t_owned_ptr< t_impl >	m_impl_ptr;
};

#endif // !defined( BATTLEFIELD_TERRAIN_MAP_H_INCLUDED )
